package CommonGui;


import java.awt.BorderLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

public class MyPanel extends JPanel{

    private static final long serialVersionUID = 1L;
    private ChkObj itms[] = new ChkObj[] { new ChkObj("one", true,"string"), 
            new ChkObj("two","checkBox"), new ChkObj("three","checkBox"), 
            new ChkObj("four","checkBox"), new ChkObj("five", true,"checkBox"),
            new ChkObj("six", true,"checkBox")    };
    private JList lst = new JList(itms);

    public MyPanel() {
        setLayout(new BorderLayout());
        
        
        add(new JScrollPane(lst));
        
        
        lst.setCellRenderer(new ChkRender());
        
       
        lst.addMouseListener(new MouseAdapter(){
            public void mouseClicked(MouseEvent e) { 
                ChkObj tmp = null;
                if (e.getClickCount() == 1) {
                    tmp = ((ChkObj) lst.getSelectedValue());
                    tmp.flagFired = !tmp.flagFired;
                    lst.repaint();
            }}});        
    }
}